<?php

require_once 'lib.php';
require_once 'lib\C2DMRegistrationHelper.php';

// If the key is sent via POST, use POST instead of GET.
if(isset($_POST['k'])){
    $_GET = $_POST;
}

$id = $_GET['id'];
$mode = $_GET['mode'];
$key = $_GET['k'];

// Create helper, and do the work.
$h = new C2DMRegistrationHelper($key, $mode, $id);
$h->perform();

// Prepare the output
$output = '<?xml version="1.0"?>';
$output .= '<C2DMRegistration>';
$output .= '<Status>'.$h->status.'</Status>';
$output .= '<C2DM_RegistrationId>'.$id.'</C2DM_RegistrationId>';
$output .= '<Mode>'.$mode.'</Mode>';
$output .= "</C2DMRegistration>";

header ("Content-Type:text/xml");
echo $output;
exit();

?>